#pragma once

#include "./circuit.hh"
#include "./instance.hh"
#include "./mtulinduction.hh"

#include <unordered_map>
#include <vector>

namespace ycspice::preprocess {

    class Subckt : public Circuit {
    public:
        Subckt(std::string name);

    public:
        virtual auto expand_spice(std::string_view inst_name, std::span<std::string> nets) const -> std::string override;

    public:
        auto add_instance(Circuit* circuit, std::string name, std::span<std::string> net_names) -> void;
        auto add_mutual_inductances(MutualInductance mutual_inductance) -> void;
    
    private:
        auto do_expand_spice(std::string_view inst_name, std::span<std::string> nets, std::stringstream& ss) const -> void;
        auto get_net(std::string net_name) -> Net*;

    public:
        auto instances() const -> std::span<Instance const> { return this->_instances; }
        
    private:
        std::vector<Instance> _instances;
        std::vector<MutualInductance> _mutual_inductances; 
        std::unordered_map<std::string, Net> _nets;
    };

}